package com.hd123.rumba.gwt.widget2.client.grid;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * RGridListener集合
 * 
 * @author LiQi
 * 
 */
public class RGridDrawListenerCollection extends ArrayList {

  private static final long serialVersionUID = 1L;

  /**
   * 触发所有监听器的buildCell事件
   * 
   * @param grid
   *          触发事件的RGrid
   * @param colDef
   *          单元格所在列的列定义
   * @param row
   *          行序号，包含表格的表头和表尾
   * @param col
   *          可见列序号
   */
  public void fireBuildCell(RGrid grid, RGridColumnDef colDef, int row, int col) {
    for (Iterator it = iterator(); it.hasNext();) {
      RGridDrawListener listener = (RGridDrawListener) it.next();
      listener.onBuildCell(grid, colDef, row, col);
    }
  }

  /**
   * 触发所有监听器的buildCell事件
   * 
   * @param grid
   *          触发事件的RGrid
   * @param colDef
   *          单元格所在列的列定义
   * @param row
   *          行序号，包含表格的表头和表尾
   * @param col
   *          可见列序号
   * @param providerData
   *          从RGridDataProvider取得的数据
   */
  public void fireRefreshCell(RGrid grid, RGridColumnDef colDef, int row, int col,
      Object providerData) {
    for (Iterator it = iterator(); it.hasNext();) {
      RGridDrawListener listener = (RGridDrawListener) it.next();
      listener.onRefreshCell(grid, colDef, row, col, providerData);
    }
  }

  /**
   * 触发所有监听器的afterRefresh事件
   * 
   * @param grid
   */
  public void fireAfterRefresh(RGrid grid) {
    for (Iterator it = iterator(); it.hasNext();) {
      RGridDrawListener listener = (RGridDrawListener) it.next();
      listener.afterRefresh(grid);
    }
  }
}
